// 本模块为首页视图相关逻辑及状态,主要用来做页面传参
import contactUs from '@/api/contactUs.js'

const state = {
    contactData:{},
}

const getters = {
    contactData(state) {
        return state.contactData
    },
}

const mutations = {
    setContactState(state, { key, value }) {
        state[key] = value
    },
}

const actions = {
    getContactData({ state, dispatch, commit }, data) {
        return new Promise((resolve, reject) => {
            contactUs.contactUs().then((res) => {
                let code = res.data.code;
                if (code == 200) {
                    commit('setContactState', {
                        key: 'contactData',
                        value: res.data.data
                    })
                    resolve(res)
                }
            }).catch((error) => {
                reject(error)
            });
        })
    },
}
export default {
    state,
    getters,
    actions,
    mutations
}